package com.bw.goods_module.home.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.bw.goods_module.R;
import com.bw.goods_module.home.HomeBannerEntity;
import com.bw.imgload_sdk.LoadImgUtils;
import com.youth.banner.adapter.BannerAdapter;

import java.util.List;

public class TopBannerAdapter extends BannerAdapter<HomeBannerEntity, TopBannerAdapter.TopBannerViewHolder> {

    public TopBannerAdapter(List<HomeBannerEntity> datas) {
        super(datas);
    }

    @Override
    public TopBannerViewHolder onCreateHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.itme_home_top,parent,false);
        ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT);
        view.setLayoutParams(params);
        return new TopBannerViewHolder(view);
    }

    @Override
    public void onBindView(TopBannerViewHolder holder, HomeBannerEntity data, int position, int size) {
        LoadImgUtils.loadMatchImg(data.imgUrl,holder.home_top_img);
    }

    class  TopBannerViewHolder extends RecyclerView.ViewHolder{

        ImageView home_top_img;

        public TopBannerViewHolder(@NonNull View itemView) {
            super(itemView);
            home_top_img = itemView.findViewById(R.id.home_top_img);
        }
    }
}
